package com.stars.module.setting.controller;

import com.stars.base.entity.Result;
import com.stars.module.setting.entity.SystemSettingVo;
import com.stars.module.setting.service.SystemSettingService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author : Rocks
 * @version : 1.0
 * @date : 2023/2/24 14:54
 * @description : 系统设置控制器
 */
@RestController
@RequestMapping("/starSetting")
public class SystemSettingController {

    private final SystemSettingService settingService;

    public SystemSettingController(SystemSettingService settingService) {
        this.settingService = settingService;
    }

    /**
     * 查询全部系统设置配置维护
     * @author : Rocks
     * @date :  2023/7/1 13:43
     * @param type 类型 1系统 2机构 3个人
     * @return Result
     */
    @RequestMapping("/getAllDefine")
    public Result loadAllDefine(String type) {
        return Result.success(settingService.loadAllDefine(type));
    }

    /**
     * 系统表单设置保存
     * @author : Rocks
     * @date :  2023/7/2 23:26
     * @param list 保存系统设置数据
     * @return Result
     */
    @RequestMapping("/saveAll")
    public Result saveAll(@RequestBody List<SystemSettingVo> list, String type) {
        return Result.result(settingService.saveAllDefine(list, type));
    }

}
